#include <bits/stdc++.h>

using namespace std;

const int N = 3e6+ 10;
int n;
int a[N];
int res[N];
int main(){
    cin >> n;
    for(int i = 0 ; i < n; i++)cin >> a[i];

    vector<int> s(n);
    int top = 0;
    for(int i = n - 1; i >= 0 ; i--){
        while(top && a[s[top]] <= a[i]) top --;
        res[i] = s[top] == 0 ? 0 : s[top] + 1;
        s[++top] = i ;
    }


    for(int i = 0; i< n; i++)cout << res[i] << " ";



    return 0;
}